package com.example.demo.fastjasondemo;

import org.junit.Before;
import org.junit.Test;
 
import com.alibaba.fastjson.JSONObject;
 
public class PersonTest {
 
	private Person person;
	
	/**
	 * 初始化对象
	 */
	@Before
	public void setUp() {
		person = new Person();
		person.setName("xianglj");
		person.setAge("20");
		person.setDesc("只是一个测试");
	}
	
	@Test
	public void test() {
		String jsonStr = JSONObject.toJSONString(person);
		System.out.println("bean to json:" + jsonStr);

		person = JSONObject.toJavaObject(JSONObject.parseObject(jsonStr), Person.class);
		System.out.println("json to bean:" + person);
	}
}